var HotPostList = React.createClass({
  getInitialState: function () {
    return {
      resultList: []
    };
  },

  componentDidMount: function () {
    $.getJSON(baseUrl + "getTextList/1/", function (result, status) {
      console.log(result.data);
      if (this.isMounted()) {
        this.setState({
          resultList: result.data
        });
      }
    }.bind(this));
  },

  render: function () {
    return (
      <div>
        <h3>热门文章</h3>
        {this.state.resultList.map(function (post) {
          var href = 'post.html?id=' + post.id;
          return (
              <a href={href} key={post.id} target="_blank">{post.title}</a>
          )
        })}
      </div>
    );
  }
});

// React.render(<Header title="博客系统"/>, document.getElementById('title'));
// React.render(<SearchBox/>, document.getElementById('search'));
// React.render(<SignForm/>, document.getElementById('sign-form'));
// React.render(<HotPostList/>, document.getElementById('hot-post'));

module.exports = HotPostList;
